#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
struct node
{
    long long num;
    long long color;
};
node a[MAXN];
long long n;
long long ans = 0;
long long T;
long long zjx = 0;
void init()
{
    ans = -1;
    zjx = 0;
    n = 0;
}
void dfs(long long deep,long long score)
{
    if(deep > n)
    {
        ans = max(ans,score);
        return;
    }
    a[deep].color = 0;
    for(long long i=deep-1;i>=1;i--)
    {
        if(a[i].color == a[deep].color)
        {
            if(a[i].num == a[deep].num)
            {
                zjx += a[deep].num;
                break;
            }
        }
    }
    dfs(deep+1,zjx);
    zjx = score;
    a[deep].color = 1;
    for(long long i=deep-1;i>=1;i--)
    {
        if(a[i].color == a[deep].color)
        {
            if(a[i].num == a[deep].num)
            {
                zjx += a[deep].num;
                break;
            }
        }
    }
    dfs(deep+1,zjx);
    zjx = score;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%lld",&T);
    while(T--)
    {
        init();
        scanf("%lld",&n);
        for(long long i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
            a[i].color = 1;
        }
        dfs(1,0);
        printf("%lld",ans);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
